//定义全局自定义指令 下载
const vdown = {
    beforeUpdate: (el, binding) => {
        if (!binding.value.url) {
            return
        }
        el.addEventListener('click', () => {
            let link = document.createElement('a')
            let url = binding.value.url
            // 这里是将url转成blob地址，
            fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
                link.href = URL.createObjectURL(blob)
                link.download = binding.value.fileName;
                document.body.appendChild(link)
                link.click()
            })
        })
    }
}
export default vdown  